<html> 
 



<head>
	  <title>Select Database</title> 
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>FossilPlot at Idaho State University</title>
		<meta name="keywords" content="Leif Tapanila, Fossil Plot, Fossilplot, FossilPlot, fossilplot, Sepkoski, compendium, diversity, paleontology, paleoecology, evolution, curve, geoscience, education, teaching">
		<meta name="description" content="FossilPlot at Idaho State University">
	</head>



<body background="ripple2.jpg">
<table width="611" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td height="95"><img src="FossilPlot-Banner.jpg" width="611" height="118" align="center"></td>
  </tr>
</table>
<table width="611" border="0" align="center">
  <tr> 
    <td width="118"> 
      <div align="left"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="117" height="25">
          <param name=movie value="button2.swf">
          <param name=quality value=high>
          <param name="BGCOLOR" value=""><param name="SCALE" value="noborder">
          <embed src="button2.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="117" height="25" bgcolor="" scale="noborder">
          </embed> 
        </object></div>
    </td>
    <td width="117"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="117" height="25">
        <param name=movie value="button3.swf">
        <param name=quality value=high>
        <param name="BGCOLOR" value=""><param name="SCALE" value="noborder">
        <embed src="button3.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="117" height="25" bgcolor="" scale="noborder">
        </embed> 
      </object></td>
    <td width="118"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="117" height="25">
        <param name=movie value="button4.swf">
        <param name=quality value=high>
        <param name="BGCOLOR" value=""><param name="SCALE" value="noborder">
        <embed src="button4.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="117" height="25" bgcolor="" scale="noborder">
        </embed> 
      </object></td>
    <td width="118"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="117" height="25">
        <param name=movie value="button5.swf">
        <param name=quality value=high>
        <param name="BGCOLOR" value=""><param name="SCALE" value="noborder">
        <embed src="button5.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="117" height="25" bgcolor="" scale="noborder">
        </embed> 
      </object></td>
    <td width="118"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="117" height="25">
        <param name=movie value="button1.swf">
        <param name=quality value=high>
        <param name="BGCOLOR" value=""><param name="SCALE" value="noborder">
        <embed src="button1.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="117" height="25" bgcolor="" scale="noborder">
        </embed> 
      </object></td>
  </tr>
</table>






 

<?php 

$debug= 0;
$vclass=$_POST['fclass']; 
$vorder=$_POST['order'];
$vphylum=$_POST['phylum'];


$username = "fossilplot";
$password = "fossilplot";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");


//select a database to work with
$selected = mysql_select_db("fossilplot",$dbhandle)
  or die("Could not select examples");

$clause_class = "(";
for($i=0;$i<sizeof($_POST["fclass"]);$i++) {
$result = mysql_query("select id from class where class_name='$vclass[$i]'");
while ($row = mysql_fetch_array($result)) {
$a[$i][0]=$vclass[$i];
$a[$i][1]= $row{'id'};
if($clause_class=="("){
   $clause_class = $clause_class.$row{'id'};
  //print "hello";
}
else{$clause_class = $clause_class.",".$row{'id'};}

}

if($debug){
print $vclass[$i];
print "<br>";
}
}

$clause_class= $clause_class.")";
if($debug){
print_r ($a);
print "clause class is ".$clause_class."<br>";
}

$clause_order = "(";
for($i=0;$i<sizeof($_POST["order"]);$i++) {
$result = mysql_query("select id from fossilplot.order where order_name='$vorder[$i]'");
while ($row = mysql_fetch_array($result)) {
$b[$i][0]=$vorder[$i];
$b[$i][1]= $row{'id'};
if($clause_order=="("){
   $clause_order = $clause_order.$row{'id'};
  //print "hello";
}
else{$clause_order = $clause_order.",".$row{'id'};}
}
if($debug){
print $vorder[$i];
print "<br>";
}
}

$clause_order= $clause_order.")";
if($debug){
echo "array b is: ";
print_r ($b);
print "clause order is ".$clause_order."<br>";
}

$clause_phylum = "(";
for($i=0;$i<sizeof($_POST["phylum"]);$i++) {
$result = mysql_query("select id from fossilplot.phylum where phylum_name='$vphylum[$i]'");
while ($row = mysql_fetch_array($result)) {
$c[$i][0]=$vphylum[$i];
$c[$i][1]= $row{'id'};
if($clause_phylum=="("){
   $clause_phylum = $clause_phylum.$row{'id'};
  //print "hello";
}
else{$clause_phylum = $clause_phylum.",".$row{'id'};}
}


if($debug){
print $vphylum[$i];
}

}

if($debug){
echo "array c is: ";
print_r ($c);
}
$clause_phylum= $clause_phylum.")";
if($debug){
print "clause phylum is ".$clause_phylum."<br>";
}


echo "<table boder=1 align=center>";
$result = mysql_query("select * from genus where class_id in $clause_class and order_id in $clause_order and phylum_id in $clause_phylum;");

//$result = mysql_query("select * from genus where order_id in $clause_order;");

while ($row = mysql_fetch_array($result)) {
if(debug){
for($i=0; $i<sizeof($a); $i++){
		  if ($a[$i][1]==$row{'class_id'}){$tmpa=$a[$i][0];}
}

for($i=0; $i<sizeof($b); $i++){
		  if ($b[$i][1]==$row{'order_id'}){$tmpb=$b[$i][0];}
}

for($i=0; $i<sizeof($c); $i++){
		  if ($c[$i][1]==$row{'phylum_id'}){$tmpc=$c[$i][0];}
}
print "<tr><td>".$row{'genus_name'}."</td>"."<td>".$tmpa."</td>"."<td>".$tmpb."</td>"."<td>".$tmpc."</td>"."</tr>";
//print "<tr><td>".$row{'genus_name'}."</td>"."<td>".$tmpb."</td>"."</tr>";
}
}


echo "</table>";

mysql_close($dbhandle);

?>
</body> 
</html>